package niit.com.classtable;

import android.app.Application;

import java.util.List;

public class CourseReposity {
    private final CourseDao courseDao;
    public CourseReposity(Application application){
        InfoRoomDatabase db=InfoRoomDatabase.getInstance(application);
        courseDao=db.getCourseDao();
    }
    public void insert(final Course course){
        InfoRoomDatabase.writeExecutor.execute(new Runnable() {
            @Override
            public void run() {
                courseDao.insert(course);
            }
        });
    }

    public void update(final Course course){
        InfoRoomDatabase.writeExecutor.execute(new Runnable() {
            @Override
            public void run() {
                courseDao.update(course);
            }
        });
    }

    public void delete(final  Course course){
        InfoRoomDatabase.writeExecutor.execute(new Runnable() {
            @Override
            public void run() {
                courseDao.delete(course);
            }
        });
    }

    public List<Course> selectAll(){
        return courseDao.selectAll();
    }
}
